﻿// JavaScript Document
$(document).ready(function(){
	$("#top_label img").hide();
	var TOP = $("#top_label").offset().top;
	
	$(window).scroll(function()
	{ 
	var offsetTop = TOP + $(window).scrollTop() +"px"; 
		$("#top_label").animate({top:offsetTop },{duration:600,queue:false}); 
	});
	gotop();
	$("#top_label").hide(); 
	soll_combo();
	
	$("#top_label").click(function(){
        $('#navigation').ScrollTo(800);
   		return false;
   });		
});

function gotop()
{
	$("#top_label img").show();
	window.onscroll=function()
	{
		if (document.documentElement.scrollTop==0&&document.body.scrollTop==0){
			$("#top_label").hide();
		}
		else
		{
			$("#top_label").fadeIn("slow"); 
			//$("#top_label").show(); 
		}
	}
}

$(function(){
	$(".p_row_8 a").click(function(){
		$(this).css({"float":"left","height":"13px","width":"13px","border":"2px solid #A1D215", "margin":"3px 4px 0 0"}).siblings()
		       .css({"float":"left","height":"13px","width":"13px","border":"1px solid #DEDEDE", "margin":"4px 5px 0 0"});
	});	


//鼠标经过商品图片
	$(".p_row_9 p").hover(
	function(){
		$(this).css({"background-color":"#FFFFFF","cursor":"pointer"});
	},
	function(){
		$(this).css({"background-color":"#F3F3F3"});
	});

//分享样式
$(".fenx_border p").toggle(
  function () {
	$("#p_fx_1").show();
    $(this).css({"background":"url(images/product_041.gif) no-repeat 0px 12px","cursor":"pointer"});
	
  },
  function () {
	$("#p_fx_1").hide();
	$(this).css({"background":"url(images/product_008.gif) no-repeat 0px 12px"});
  }
); 


// 套餐选项卡
$(".com_left_title li").click(function(){
	var i = ($(".com_left_title li").index(this))+1;
	if (i == 1)
	{
		soll_combo();
	}else
	{
		soll_combo1();		
	}
	$(this).attr("class","nav_1").siblings(".nav_1").attr("class","nav_2");	  
});


// 详细参数选项卡
$(".depict_title ul li:not(.nav_p)").click(function(){
	var i = ($(".depict_title li").index(this))+1;
	var detail ="#detail_par_1,#detail_par_2,#detail_par_3";
	$(this).attr("class","nav_1").siblings(".nav_1").attr("class","nav_2");	   
	$("#detail_par_" + i).slideDown('1500');
	$(detail).not($("#detail_par_" + i)).slideUp('1500');
});


// 交易评价选项卡
$("div.pj_left_title ul li").click(function(){					   
	//$(this).attr("class","title_1").siblings().attr("class","title_2");	
	$(this).attr("class","nav_1").siblings(".nav_1").attr("class","nav_2");	   
		var index = $("div.pj_left_title ul li").index(this);	
		$("div.pingjia_body > div")   	
				.eq(index).show()   
				.siblings().hide();
});


// 商品咨询选项卡
$("div.ady_left_title ul li:not(.nav_p)").click(function(){											 
	$(this).attr("class","nav_1").siblings(".nav_1").attr("class","nav_2");	   										 
		var index = $("div.ady_left_title ul li").index(this);	
		$("div.ady_hight > div")   	
				.eq(index).show()   
				.siblings().hide();
});

$(".ady_body:odd").addClass("ady_odd");  /* 奇数行添加样式*/
$(".ady_body:even").addClass("ady_even"); /* 偶数行添加样式*/


	
//鼠标经过商品图片
	$("div.tjw_pro_img").hover(
	function(){
		$(this).css({"background":"url(images/product_038.gif) no-repeat","cursor":"pointer"});
	},
	function(){
		$(this).css({"background":"url(images/product_034.gif) no-repeat"});
	});

});


function soll_combo1()
{
	 $.getJSON('test1.json', function(data) {
	 $('#soll_content').empty();
	  var html = '';
	  $.each( data  , function(commentIndex, comment) {
		html +='<div class="combo_list"><img src="images/com/' + comment['img'] + '" width="98" height="98"/>';
		html +='<p>' + comment['title'] + '</p>';
		html +='<p>原价：<span class="font_1">￥' + comment['price_1'] + '</span></p>';
		html +='<p>套餐价：<span class="font_2">￥' + comment['price_2'] + '</span></p>';
		html +='<p class="com_button" id="' + comment['num'] + '"></p>';
		html +='</div>';
	  })
		//获取JSON长度
		function getJsonLength(jsonData){
			var jsonLength = 0;
			for(var item in jsonData) 
			jsonLength++;
			return jsonLength;
		}
		var wid = (getJsonLength(data)*132);
		//alert(wid);
		$("#allComNum").text(getJsonLength(data));
		$(".combor_soll_width").css({"width": + wid + "px"});
		$('#soll_content').html(html);
	});
}


function soll_combo()
{
	 $.getJSON('test.json', function(data) {
	 $('#soll_content').empty();
	  var html = '';
	  $.each( data  , function(commentIndex, comment) {
		html +='<div class="combo_list"><img src="images/com/' + comment['img'] + '" width="98" height="98"/>';
		html +='<p>' + comment['title'] + '</p>';
		html +='<p>原价：<span class="font_1">￥' + comment['price_1'] + '</span></p>';
		html +='<p>套餐价：<span class="font_2">￥' + comment['price_2'] + '</span></p>';
		html +='<p class="com_button" id="' + comment['num'] + '"></p>';
		html +='</div>';
	  })
		//获取JSON长度
		function getJsonLength(jsonData){
			var jsonLength = 0;
			for(var item in jsonData) 
			jsonLength++;
			return jsonLength;
		}
		var wid = (getJsonLength(data)*132);
		//alert(wid);
		$("#allComNum").text(getJsonLength(data));
		$(".combor_soll_width").css({"width": + wid + "px"});
		$('#soll_content').html(html);
	});
}

